# -*- coding:utf-8 -*-

from .settings_common import *

# web服务地址， 该配置项其实是给 WSGI SERVER （如 gunicorn, cherrypy） 读取的
WEB_SERVER_LISTEN_ADDR = ('0.0.0.0', 8080)

CELERY_BROKER_URL = 'amqp://yjyx:sdfsdf@127.0.0.1/yjyx'
MQ_MGR_URL = 'localhost:15672'
MQ_MGR_USER = 'test'
MQ_MGR_PASSWD = 'yjjcy1'
MQ_CHORD_VHOST = 'yjyx'
MQ_CHORD_QUEUE = 'paperanalyzer'
CELERY_REDIS_PASSWD = 'yjyxqaredisyjyx'

GUNICORN_WORKER_NUMBER = multiprocessing.cpu_count()

# Database

DATABASES['default']['NAME'] = '111'
DATABASES['default']['USER'] = '111'
DATABASES['default']['PASSWORD'] = '11111'
DATABASES['default']['HOST'] = '127.0.0.1'

DEBUG = True

RedisInfo = {
    "host": "localhost",
    "port": "6379",
    "password": "yjyxqaredisyjyx",
    "lock_db": 1,
}
# 支付宝支付设置

ALIPAY_CALLBACK_ADDR = 'qa.momself.cn'
DOMAIN_URL = "http://qa.momself.cn"
CALLBACK_URL = ''


class alipay_settings:
    # 安全检验码，以数字和字母组成的32位字符
    ALIPAY_KEY = 'h1timcb8po1egdyo51h4s886fmtgouqt'  # momself

    # 合作身份者ID，以2088开头的16位纯数字
    ALIPAY_PARTNER = '2088521507106405'  # momself

    # 签约支付宝账号或卖家支付宝帐户
    ALIPAY_SELLER_EMAIL = 'momself@qq.com'  # 'jcyrss@163.com'

    ACCOUNT_NAME = u'杭州摩米文化创意有限公司'  # 商家账户名

    ALIPAY_INPUT_CHARSET = 'utf-8'

    ALIPAY_SIGN_TYPE = 'MD5'
    ALIPAY_MOBILE_SIGN_TYPE = 'RSA'
    ALIPAY_SHOW_URL = ''
    # 访问模式,根据自己的服务器是否支持ssl访问，若支持请选择https；若不支持请选择http
    ALIPAY_TRANSPORT = 'https'

    # 付完款后跳转的页面（同步通知） 要用 http://格式的完整路径，不允许加?id=123这类自定义参数
    ALIPAY_RETURN_URL_STUDENT_BUY_PRODUCT = 'http://%s/student/payment/alipay_buy_product_result.html' % \
                                            ALIPAY_CALLBACK_ADDR
    ALIPAY_RETURN_URL_STUDENT_BUY_ACTUAL = "http://%s/retail/success?order_id=%s"
    # 交易过程中服务器异步通知的页面 要用 http://格式的完整路径，不允许加?id=123这类自定义参数
    ALIPAY_NOTIFY_URL_STUDENT_BUY_PRODUCT = 'http://%s/api/payment/ali/student_buy_product_notify' % \
                                            ALIPAY_CALLBACK_ADDR
    ALIPAY_MOBILE_NOTIFY = 'http://%s/api/payment/ali/mobilepaynotify' % ALIPAY_CALLBACK_ADDR


class wx_settings:
    APP_ID = "wxdfce2aed95235cde"
    APP_SECRET = "9709677bde62d5c5f82a6ed6d22e8aa8"
    MCH_ID = "1605179768"  # 商户号
    MCH_SECRET = "MOMsINsect0809OIHVB456uu217hvd56"  # 商户Key
    MCH_SSL_CERT_PATH = "/home/yjyx/yijiao_src/yijiao_main/cert/apiclient_cert.pem"  # 商户证书路径
    MCH_SSL_KEY_PATH = "/home/yjyx/yijiao_src/yijiao_main/cert/apiclient_key.pem"  # 商户私钥Key
    # 微信认证重定向回域名， 在微信开发平台 开发者中心->接口权限表->网页服务->网页授权获取用户基本信息->OAuth2.0网页授权:授权回调页面域名
    WX_AHTH_REDIRECT_DOMAIN = 'qa.momself.cn'
    TEMPLATE_ID_DETAIL = {
        1: {
            'id': 1,
            'template_id': 'yBG-JVBUh-Z921sdPdB5NOk0Q1Ckubn-gT9T3HcIwP8',
        },
        2: {
            'id': 2,
            'template_id': 'bk_gi7l2SUnpOlyEmGIer5Nn8AW6U1JyFmzjItWjACY',
        },
        3: {
            'id': 3,
            'template_id': '91IQr_p2oFDU2B2pgvXqKAJLvepTbPcxW20Eeox1Wjk',
        }
    }
    WECHAT_MOBILE_NOTIFY = "%s/api/payment/wx/%s/mobilepaynotify"

    pay_qrcode = {'appid': 'wxe062e736b5bc8322',
                  'mchid': '1336170201',
                  'key': 'YJYXINsect0809OIHVB456uu217hvd56',
                  'trade_type': 'NATIVE'}
    pay_mp = {'appid': 'wx76a6f46b670c4e92',
              'mchid': '1498739252',
              'key': 'YJYXINsecttestOIHVB456uu217mpp56',
              'trade_type': 'JSAPI'}
    pay_qrh5 = {'appid': 'wx0e6b325998e30fd7',
                'mchid': '1497122102',
                'key': 'YJYXINsectstudOIHVB456uu217hvd56',
                'trade_type': 'MWEB'}
    pay_student = {'appid': 'wx0e6b325998e30fd7',
                   'mchid': '1497122102',
                   'key': 'YJYXINsectstudOIHVB456uu217hvd56',
                   'trade_type': 'APP'}
    pay_teacher = {'appid': 'wxa5f5ab72238f691e',
                   'mchid': '1497215662',
                   'key': 'YJYXINsectteacOIHVB456uu217her56',
                   'trade_type': 'APP'}
    pay_parent = {'appid': 'wx35a30afb142d59ea',
                  'mchid': '1497119662',
                  'key': 'YJYXINsectpareOIHVB456uu217ntr56',
                  'trade_type': 'APP'}
    _pay_tuple = (('qrcode', pay_qrcode),
                  ('parent', pay_parent),
                  ('student', pay_student),
                  ('teacher', pay_teacher),
                  ('qrh5', pay_qrh5),
                  ('mp', pay_mp))


# 七牛云设置
QINIU_accessKey = 'cgPnimqdk-NnJx7FhwsShV7iArJFp_Z1iOl4Vjyy'
QINIU_secretKey = 'mLMW2-7cqJULTRa7DzJqwPsh2D1wPdh9yT-bNLqN'
QINIU_videoBucketName = 'test-video'
QINIU_videoBucketDomain = 'http://qa-web-video-cdn.zgyjyx.com/'
QINIU_imgBucketName = 'test-img'
# QINIU_imgBucketDomain    = 'http://oivj4vcuo.bkt.clouddn.com/'
QINIU_imgBucketDomain = 'http://cdn-qa-static.zgyjyx.net/'
# QINIU_imgBucketDomain    = 'http://7xkxyy.com1.z0.glb.clouddn.com/' #pj
QINIU_textBucketName = 'test-text'
QINIU_textBucketDomain = 'http://cdn-qa-static.zgyjyx.net/'
QINIU_docBucketName = "test-img"
QINIU_docBucketDomain = "http://cdn-qa-static.zgyjyx.net/"

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': [
            '127.0.0.1:11211',
        ],
        'TIMEOUT': 60
    },

    'onedaycache': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': [
            '127.0.0.1:11211',
        ],
        'TIMEOUT': 86400
    }
}

# FATAL = CRITICAL = 50 ERROR = 40  WARN = WARNING = 30 INFO = 20 DEBUG = 10 NOTSET = 0
LOG_LEVEL = 'DEBUG'

django_sys_log_setting = {
    'handlers': ['django_file'],
    'level': LOG_LEVEL,
    'propagate': False,
}

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse',
        },
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
    },
    'formatters': {
        'verbose': {
            'format': '%(asctime)s %(message)s',
            'datefmt': '%m%d_%H:%M:%S'
        },
        'simple': {
            'format': '%(message)s'
        },
    },
    'handlers': {
        'null': {
            'class': 'logging.NullHandler',
        },
        'console': {
            'level': LOG_LEVEL,
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'django_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/django.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'mgr_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/mgr.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },

        'student_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/student.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'datamodel_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/model.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'stats_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/stats.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'alipay_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/alipay.log',
            'maxBytes': 1024 * 1024 * 3,  # 3MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'sms_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/sms.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'version_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/version.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 20,
            'formatter': 'verbose'
        },
        'danger_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/danger.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 20,
            'formatter': 'verbose'
        },
        'news_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/news.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'wechat_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/wechat.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },
        'proxy_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/home/yjyx/log/proxy.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 50,
            'formatter': 'verbose'
        },

    },
    'loggers': {
        'django.db.backends': {
            'handlers': ['console'],
            'level': LOG_LEVEL,
        },
        'django.request': django_sys_log_setting,
        'django.security': django_sys_log_setting,
        'py.warnings': django_sys_log_setting,
        # 'django.db.backends': django_sys_log_setting,

        'mgr': {
            'handlers': ['mgr_file'],
            'level': LOG_LEVEL,
        },

        'student': {
            'handlers': ['student_file'],
            'level': LOG_LEVEL,
        },

        'datamodel': {
            'handlers': ['datamodel_file'],
            'level': LOG_LEVEL,
        },

        'stats': {
            'handlers': ['stats_file'],
            'level': LOG_LEVEL,
        },

        'alipay': {
            'handlers': ['alipay_file'],
            'level': LOG_LEVEL,
        },
        'sms': {
            'handlers': ['sms_file'],
            'level': LOG_LEVEL,
        },
        'version': {
            'handlers': ['version_file'],
            'level': LOG_LEVEL,
        },

        'danger': {
            'handlers': ['danger_file'],
            'level': LOG_LEVEL,
        },

        'news': {
            'handlers': ['news_file'],
            'level': LOG_LEVEL,
        },
        'wechat': {
            'handlers': ['wechat_file'],
            'level': LOG_LEVEL,
        },
        'proxy': {
            'handlers': ['proxy_file'],
            'level': LOG_LEVEL,
        },
    }
}
ES_URL = "http://121.199.7.202:19200/"
ES_USER = "yjyx"
ES_PASSWORD = "whynotyj#1"
